#include "spritexanimation.h"

Animation* SpriteXAnimation::create(Texture2D* texture,SpriteX* spritex,int actionidx)
{
    int transform;
    int frameidx;
    int tileidx;
    int seqcount = spritex->actionList[actionidx].hdr.sequencecount;
    Rect rect;
    SpriteFrame* spriteFrame = NULL;
    Vector<SpriteFrame*> v(seqcount);
    
    for( int i = 0 ; i < seqcount ; i ++ ){
        frameidx = spritex->actionList[actionidx].data.seq[i].sequence;
        tileidx = spritex->frameList[frameidx].data.tile[0].index;
        tile_t & t = spritex->tileList[tileidx];
        rect.setRect(t.x,t.y,t.w,t.h);
        spriteFrame = SpriteFrame::createWithTexture(texture,rect);
        v.pushBack(spriteFrame);
    }

    return createWithSpriteFrames(v);
}
/*
static SpriteXAnimation* SpriteXAnimation::create(void)
{

}

static SpriteXAnimation* SpriteXAnimation::createWithSpriteFrames(const Vector<SpriteFrame*>& arrayOfSpriteFrameNames, float delay = 0.0f, unsigned int loops = 1){}
static SpriteXAnimation* SpriteXAnimation::create(const Vector<AnimationFrame*>& arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops = 1){}
*/
